﻿Imports MySql.Data.MySqlClient
Public Class add_emadd
    Dim mysql As MySqlConnection
    Private Sub btn_home_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_home.Click
        Dim NextForm As main = New main()
        '  Dim NextForm As main_user = New main_user()
        NextForm.Show()
        Me.Close()
    End Sub
    Private Sub add_emadd_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MySql = New MySqlConnection
        MySql.ConnectionString = "server=ryh1;port = 3306;user id=" + "june" + ";password=" + "software" + ";database=telephone;Character Set =utf8"

        'mysql.ConnectionString = "Server=172.26.8.182;Database=testremote;Uid=root;Pwd=software;CharSet=UTF8;"
        Try
            MySql.Open()
            '    MsgBox("CONNECTED TO DATABASE")
        Catch ex As Exception
            MsgBox("Can't Connect to database" + ex.Message)

            Me.Close()
        End Try
    End Sub
    Private Sub btn_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_save.Click

        Dim mySqlCommand As New MySqlCommand
        Dim mySqlAdaptor As New MySqlDataAdapter
        Dim mySqlReader As MySqlDataReader

        Dim mysql As MySqlConnection

        Try
            mySqlCommand.CommandText = "INSERT INTO manage (user_name,branch_name,mobile_tel,house_tel,clinic_tel) VALUES ('" & txt_name.Text & "', '" & Txt_bra.Text & "', '" & Txt_mobile.Text & "','" & Txt_home.Text & "','" & txt_clinic.Text & "');"
            mySqlCommand.CommandType = CommandType.Text
            mySqlCommand.Connection = mysql
            mySqlCommand.ExecuteNonQuery()

            Dim nextform As Form1 = New Form1()
            nextform.Show()
            Me.Close()
        Catch ex As Exception
            MsgBox(ex.ToString)
            mysql.Close()
        End Try

    End Sub

    
End Class